#include <math.h>
#include <iostream>
using std::cout;
using std::endl;
//友元之普通函数的形式
class Point{
public:
    Point(int x, int y)
    :_x(x)
    ,_y(y)
    {

    }
    //将当前函数声明为了Point的友元函数
    friend float distance(const Point & lhs,const Point & rhs);

private:
    int _x;
    int _y;
};
//可以将当前的distance函数声明为Point的友元
float distance(const Point & lhs,const Point & rhs){
    //让Point提供公有的get函数i
    //sqrt(a *a + b * b)
    int x = lhs._x - rhs._x;
    int y = lhs._y - rhs._y;
    return sqrt(pow(x , 2) + pow(y, 2));
}


void test(){
    float result = distance(Point(1, 1), Point(4, 5));
    cout << result << endl;
}

int main()
{
    test();
    return 0;
}

